﻿using Compass.LogisticService.Infrastructure;
using Compass.Wasm.Server.Services.Logistics;
using Compass.Wasm.Shared;
using System.ComponentModel.DataAnnotations;
using Compass.Wasm.Shared.Logistics;

namespace Compass.Wasm.Server.Controllers.Logistics;

[Route("api/[controller]")]
[ApiController]
[UnitOfWork(typeof(LogisticDbContext))]
public class ImportExportInfoController : ControllerBase
{
    #region ctor
    private readonly IImportExportInfoService _service;
    public ImportExportInfoController(IImportExportInfoService service)
    {
        _service = service;
    }
    #endregion


    #region 基本增删改查
    [HttpGet("All")]
    public async Task<ApiResponse<IEnumerable<ImportExportInfoDto>>> GetAll() => await _service.GetAllAsync();

    [HttpGet("{id}")]
    public async Task<ApiResponse<ImportExportInfoDto>> GetSingle([RequiredGuid] Guid id) => await _service.GetSingleAsync(id);

    [HttpPost("Add")]
    public async Task<ApiResponse<ImportExportInfoDto>> Add(ImportExportInfoDto dto) => await _service.AddAsync(dto);

    [HttpPut("{id}")]
    public async Task<ApiResponse<ImportExportInfoDto>> Update([RequiredGuid] Guid id, ImportExportInfoDto dto) => await _service.UpdateAsync(id, dto);

    [HttpDelete("{id}")]
    public async Task<ApiResponse<ImportExportInfoDto>> Delete([RequiredGuid] Guid id) => await _service.DeleteAsync(id);

    #endregion
}